package com.lkz.controller;

import com.lkz.entity.Role;
import com.lkz.entity.RoleBean;
import com.lkz.service.IEmployeeService;
import com.lkz.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 *数据图
 */
@Controller
public class CartogramController {
    @Autowired
    private IEmployeeService employeeService;
    @Autowired
    private IRoleService roleService;
    @RequestMapping("/echarts/list")
    @ResponseBody
    public List<RoleBean> myECharts(){
        List<Role> list = roleService.list();
        List<RoleBean> roleBeanList =new ArrayList();
        for (int i=0;i<list.size();i++) {
            RoleBean roleBean = new RoleBean();
            String roleName =list.get(i).getRoleName();
            roleBean.setCount(employeeService.selectByRoleName(roleName));
            roleBean.setName(roleName);
            roleBeanList.add(roleBean);
        }
        return roleBeanList;
    }
}